#ifndef BARCODEITEM_H_
#define BARCODEITEM_H_

#include "Arduino.h"
#include <EEPROM.h>
#include "EEPROMAnything.h"

PROGMEM const int8_t _max_defect_count = 50;

PROGMEM const int8_t ee_barcode = 2;//char[10]
PROGMEM const int8_t ee_type = 13;//int8_t
PROGMEM const int8_t ee_order_type = 14; //int8_t
PROGMEM const int8_t ee_label_no = 15; // 13-14; int16_t
PROGMEM const int8_t ee_operator = 17; // 15-20; char[6]
PROGMEM const int8_t ee_good_qty = 23; // 21-22; int16_t
PROGMEM const int8_t ee_total_defect = 25; // int8_t
PROGMEM const int8_t ee_defect_index = 100; //int8_t

//typedef struct DefectItem
//{
	//uint8_t DEFECT_ID;
	//int8_t QTY;
//}  DefectItems;

class BarcodeItem
{
	public:
	BarcodeItem();

	void AddDefect(uint8_t, uint8_t);
	void RemoveDefect(uint8_t);
	void ClearDefect();

	void SetQcId(char[]);	
	char* GetQcId();
	//boolean HasQcId(){ for(int x=0;x<sizeof(_operator);x++) if(_operator[x]=='\0' || _operator[x]=='\n') return true; else return false;}
		
	char* GetBarcode();
	void SetBarcode(char[]);
	//boolean HasBarcode(){ for(int x=0;x<sizeof(_barcode);x++) if(_barcode[x]=='\0' || _barcode[x]=='\n') return true; else return false;}
	
	uint8_t GetHeType();
	void GetHeTypeChar(char&);
	void SetHeType(uint8_t);
	
	void SetLabelNo(uint16_t);
	uint16_t GetLabelNo();
	
	//struct DefectItem GetDefectItem(uint8_t);
	uint16_t GetDefectQty(uint8_t);
	uint16_t GetTotalDefectQty();
	//int8_t GetNumDefect();
	int8_t FindDefectIndex(uint8_t);
	//String GetDefectQtyString(uint8_t);
	
	uint16_t GetGoodQty();
	void SetGoodQty(uint16_t);
	
	int8_t IsReady();
	
	void Reset();

	private:
	char _barcode[10];
	uint8_t _he_type;
	uint16_t _labelNo;
	char _operator[6];
	uint32_t _orderQty;
	uint16_t _goodQty;
	uint16_t _defQty;
	uint16_t _totalDefectQty;
	int8_t _defectIndex;
	int8_t _is_ready;

	//struct DefectItem defectItem[30];
};


#endif /* BARCODEITEM_H_ */